package net.jueb.frameworkDemo.orm.mapdb;
import java.io.File;  
import java.util.concurrent.ConcurrentNavigableMap;  
  
import org.mapdb.DB;  
import org.mapdb.DBMaker;
import org.mapdb.Serializer;  
  
public class MapsTest {  
    public static void main(String[] args) {  
        //fluet式    无则创建，有则打开，需密码校验  
        DB db = DBMaker.fileDB(new File("mapdb.db")).closeOnJvmShutdown().make();  
        ConcurrentNavigableMap<Integer, String> map = db.treeMap("map")
                .keySerializer(Serializer.INTEGER)
                .valueSerializer(Serializer.STRING).create();
        map.put(1, "test1");  
        map.put(2, "test2");  
        //提交持久化   
        db.commit();  
        map.put(3, "test3");  
        // map.keySet() is  [1,2,3]  
        System.out.println(map);  
        //回滚  
        db.rollback();   
        // map.keySet() is  [1,2]  
        System.out.println(map);  
        db.close();  
    }  
}